package com.paginasenlanube.model;

import java.io.Serializable;

import java.util.LinkedHashSet;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name = "header")
 public class Header implements Serializable{
	
  /**
	 * 
	 */
  private static final long serialVersionUID = 1L;
  private long id;
  private Image logo;
  private String name;
  private Set<Image> carrousel = new LinkedHashSet<Image>();
  private boolean logoImg;
  
  public Header(){
	  
  }


  @Id
  @GeneratedValue
  @Column(name = "id")
  public long getId() {
    return id;
  }

  public void setId(long value) {
    id = value;
  }

  @OneToOne(cascade = CascadeType.ALL)
  public Image getLogo() {
	return logo;
  }

  public void setLogo(Image logo) {
	this.logo = logo;
  }

  @OneToMany(mappedBy="header_id",fetch = FetchType.EAGER)
  @OrderBy("position ASC")
  public Set<Image> getCarrousel() {
	return carrousel;
  }

  public void setCarrousel(Set<Image> carrousel) {
	this.carrousel = carrousel;
  }

  @Transient
  public boolean isLogoImg() {
	  if(this.logo != null && !this.logo.getFileName().isEmpty()){
		  logoImg = true;
		}
	return logoImg;
  }


  public void setLogoImg(boolean logoImg) {
	this.logoImg = logoImg;
  }


public String getName() {
	return name;
}


public void setName(String name) {
	this.name = name;
}




}
